<?php
echo '112';
require_once "./php/funcs.php";
global $CONFIG;

$handler = new RedisSessionHandler(
    'DIDAOYP_AUTH_SESSION', $CONFIG['REDIS']['HOST'], $CONFIG['REDIS']['PORT']
);
require_once "./php/session_common.php";
if (!session_id()) {
    session_start();
}

$isWeixinBrowser = isWeixinBrowser();
if ($isWeixinBrowser == 1) {
    if (isset($_SESSION['weixin_didao_openid']) &&  $_SESSION['weixin_didao_openid'] != 'unknown') {
        $openid = $_SESSION['weixin_didao_openid'];
    } else//微信授权oauth2授权，获取code
    {
        $_SESSION['referer']
            = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        $redirectUrl = $CONFIG['UrlPrefix']
            . "./apiRedPackatList.php";
        $redirectUrl = urlencode($redirectUrl);
        $baseUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="
            . $CONFIG['appid'] . "&response_type=code&scope=snsapi_base";
        $finalUrl = $baseUrl
            . "&redirect_uri=$redirectUrl&state=fzUnicom#wechat_redirect";
       echo $redirectUrl;
        // header("Location:$finalUrl");
        exit();
    }
} else {
//$openid="o3M-NuM50oFAMrwIjH_Q5iLmWIQU";
    echo "<h1>请从微信手机端访问，参与活动哦~</h1></script>";
    exit();
//    exit();
}

?>
